%1.2
f0=300;
fs=8000;
phi=0.5*2*pi;
x=0:400;%50ms
y=sin((2*pi*(f0/fs)*x)+phi);

bits=4:4:16;
i=1;
N=[];
for b=bits
    y2=bitround(y,b);
    figure(1);
    subplot(2,2,i);
    hist(y2-y);
    title(sprintf('hist with %d bits',b));
    xlabel('aantal');
    ylabel('foutmarge');

    figure(2);
    subplot(2,2,i);
    stem(x,y2-y);
    title(sprintf('plot with %d bits',b));
    xlabel('n');
    ylabel('y difference');
    i=i+1;
end